<!DOCTYPE html>
<html>
	<head>
		<meta charset="UTF-8">
		<title></title>
	</head>
	<body>
		<p>
			用户
			<input class="user" type="text" value="" />
		</p>
		
		<p>
			密码
			<input class="pas" type="password" name="" id="" value="" />
		</p>
		
		<p>
			<input type="button" id="btn" value="登录" />
		</p>
	</body>
	<script src="http://libs.baidu.com/jquery/2.0.0/jquery.min.js"></script>
	<script type="text/javascript">
		$("#btn").click(function(){
			var data = {
				"username":$(".user").val(),
				"password":$(".pas").val()
			}
			login(data)
		})
		function login(data){
			$.ajax({
				type:"post",
				url:"http://120.48.109.174:8081/user/login",
				async:true,
				data:data,
				success:function(res){
					var token = res.body.token
					if(token){
						localStorage.setItem("token",token);
						alert("登录成功")
						location.href = "index.html";
					}else{
						alert("登录失败")
					}
				}
				
			});
		}
		
	</script>
</html>
